package com.tkgarment.system.dispatcher;

import com.opensymphony.xwork2.ActionContext;
import java.io.IOException;
import java.util.Locale;

import javax.servlet.FilterChain;
import javax.servlet.FilterConfig;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;

import org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter;

public class Struts2Dispatcher extends StrutsPrepareAndExecuteFilter {
	//private String encoding;
	@Override
	public void destroy() {
		// TODO Auto-generated method stub
	}

	@Override
	public void doFilter(ServletRequest request, ServletResponse response,
			FilterChain next) throws IOException, ServletException {
		// Respect the client-specified character encoding
		// (see HTTP specification section 3.4.1)
		if (null == request.getCharacterEncoding()) {
			request.setCharacterEncoding("UTF-8");
		}
		   //       System.out.println(encoding);
		response.setContentType("text/html; charset=UTF-8");
		response.setCharacterEncoding("UTF-8");
                Locale.setDefault(Locale.US);
             
               
		super.doFilter(request, response, next);
	}
	
	@Override
	public void init(FilterConfig filterConfig) throws ServletException {
		super.init(filterConfig);
		/*encoding = filterConfig.getInitParameter("requestEncoding");

		if (encoding == null)
			encoding = "UTF-8";
		*/
		
	}
}
